<template>
	<view class="bg-gray1" style="min-height: 100vh;">
		<cu-custom :bgColor="'bg-'+theme.backgroundColor" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">提现记录</block>
		</cu-custom>
		<view class=""
			style="height: 120rpx;background-image: linear-gradient(#FD8CA8, #FFFFFF);padding: 20rpx 20rpx 0">
			<view class="bg-white flex-row-center text-center"
				style="border-top-left-radius: 15rpx;border-top-right-radius: 15rpx;height: 100rpx;">
				<view class="text-black">累计成功提现：</view>
				<view class="text-price text-xxl text-red">{{comData}}</view>
			</view>
		</view>
		<view class="" style="padding: 20rpx 20rpx;">
			<view class="cu-list menu-avatar withdraw-list bg-white">
				<view class="cu-item margin-top padding-bottom" v-for="(item,index) in distributionWithdrawList"
					:key="index" @click="jumpDetail(item.id)">
					<view class="cu-avatar round lg"
						:style="userInfo.headimgUrl?'background-image:url(' + userInfo.headimgUrl + ')':''">
						{{!userInfo.headimgUrl ? '头' : ''}}
					</view>
					<view class="content font-weight">
						<view class="text-gray text-sm" v-if="item.createTime">{{item.createTime}}</view>
						<!-- <view class="text-gray text-sm flex">订单编号：{{item.paymentDetail}}</view> -->
					</view>
					<view class="">
						<view class="">
							<text v-if="item.status == '0'" class="text-orange">审核中</text>
							<text v-if="item.status == '1'" class="text-green">审核通过</text>
							<text v-if="item.status == '2'" class="text-red">审核不通过</text>
						</view>
						<view class="text-xl text-right margin-right-sm text-price" style="margin-top:10rpx">
							{{item.amount}}
						</view>
					</view>
					<text class="cuIcon-right text-gray text-xs"></text>
				</view>
			</view>
			<view class="margin-top80" :class="'cu-load ' + (loadmore?'loading':'over')"
				v-if="distributionWithdrawList&&distributionWithdrawList.length>9"></view>
		</view>
	</view>
</template>

<script>
	const util = require("utils/util.js");
	const app = getApp();
	import api from 'utils/api'

	export default {
		data() {
			return {
				CustomBar: this.CustomBar,
				theme: app.globalData.theme, //全局颜色变量
				userInfo: {},
				comData: 0,
				page: {
					current: 1,
					size: 10,
					descs: 'create_time'
				},
				distributionWithdrawList: [],
				loadmore: true
			}
		},
		onLoad() {
			this.userInfo = uni.getStorageSync('user_info')
		},
		onShow() {
			app.initPage().then(res => {
				this.getCommission()
				this.distributionWithdrawList = []
				this.getDistributionWithdrawListData()
			})
		},
		onReachBottom() {
			if (this.loadmore) {
				this.page.current = this.page.current + 1;
				this.getDistributionWithdrawListData();
			}
		},
		methods: {
			getCommission() {
				api.getCommissionById(this.userInfo.id).then(res => {
					this.comData = res.data && res.data.applyComplete ? res.data.applyComplete : 0
				})
			},
			getDistributionWithdrawListData() {
				api.getExtractRecord(this.page).then(res => {
					let dataList = res.data.records;
					this.distributionWithdrawList = [...this.distributionWithdrawList, ...dataList];
					if (dataList.length < this.page.size) {
						this.loadmore = false;
					}
				});
			},
			// 跳转到佣金详情页面
			jumpDetail(id) {
				uni.navigateTo({
					url: '/pages/distribution/distribution-withdraw-detail/index?id=' + id
				})
			}
		}
	}
</script>

<style>
	page {
		background-color: #FFFFFF;
	}

	.withdraw-list-bg {
		height: 420rpx;
		position: relative;
	}

	.title-text {
		position: absolute;
		top: 15%;
		z-index: 1024;
		text-align: center;
		width: 100%;
	}

	.title-text-1 {
		font-size: 68rpx;
	}

	.title-image {
		width: 100vh;
		height: 100%;
	}

	.withdraw-list {
		border-radius: 30rpx !important;
		margin: 0rpx auto;
		border-radius: 10rpx;
	}

	.margin-top120 {
		margin-top: 120rpx;
	}

	.font-weight {
		font-weight: 300;
	}
</style>